﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GUI.Forms;
using BusinessObjects.Objects;
using SharedBusinessLogic.Models;


namespace GUI.Controllers
{
	internal sealed class OrganisationController : BaseTpController
	{
		#region Members

		OrganisationForm organisationForm;
		OrganisationModel organisationModel;
		

		#endregion

		#region Construction

		public OrganisationController()
		{
			this.organisationModel = new OrganisationModel();
			this.organisationForm = new OrganisationForm(this);
			
		}

		#endregion

		#region Methods

		public override void Save()
		{
			organisationModel.SaveOrganisation(organisationForm.MyModel);
			
		}

		public void OpenDialog(bool modal)
		{
			OrganisationObject organisationObject = new OrganisationObject();
			this.organisationForm.MyModel = organisationObject;
			this.organisationForm.IsNew = true;
			ShowForm(modal);
		}

		public void OpenDialog(OrganisationObject organisationObject, bool modal)
		{
			this.organisationForm.MyModel = organisationObject;
			this.organisationForm.SetFieldValues();
			
			ShowForm(modal);
		}

		private void ShowForm(bool modal)
		{
			if (modal)
			{
				this.organisationForm.ShowDialog();
			}
			else
			{
				this.organisationForm.Show();
			}
			this.organisationForm.Dirty = false;
		}
		
		

		#endregion

	}
}
